<template>
  <div class="">
    <div class="page-filter mb10 fl">
      <el-form ref="filter" :model="filter" label-width="0">
        <el-form-item class="mr10 mb5 fl">
          <ProFilter v-model="filter.pro_id" />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl">
          <AccountSelect v-model="filter.account_id" />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl">
          <SupplierSelect v-model="filter.sup_id" />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl">
          <el-input v-model="filter.describes" placeholder="描述" size="small" clearable />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" style="width: 300px">
          <el-button class="fl"  size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
          <el-button class="fl" type="primary" size="small" @click="getList()">查 询</el-button>
          <!-- <el-button class="fl" 
            type="primary"
            size="small"
            @click="handleDialog({dRef: 'dialog', dTitle: '新增出纳付款', dType: 'add', dField: dField})"
          >新 增</el-button> -->
        </el-form-item>
      </el-form>
    </div> 
    <el-table v-loading="app.loading" class="search-table" :data="list" border 
      :summary-method="getSummaries"
      show-summary
      fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="账户名称" min-width="220px" prop="account_name" />
      <el-table-column label="供应商/公司名称" min-width="220px">
        <template slot-scope="{row}">
          <span v-if="row.sup_name">{{ row.sup_name }}</span>
          <span v-if="row.company">{{ row.company }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="项目名称" min-width="260px" prop="pro_name" /> -->
      <el-table-column label="项目名称" min-width="220px">
        <template slot-scope="{row}">
          <span v-if="row.p_name">{{ row.p_name }}</span>
          <span v-else>{{ row.pro_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="付款金额" align="right" width="140px">
        <template slot-scope="{row}">
          {{ app.toFix(row.money, 2) }}
        </template>
      </el-table-column>
      <el-table-column label="付款日期" align="center" width="140px" prop="payment_date" />
      <el-table-column label="付款类型" width="160px" prop="v_type_name" />
      <el-table-column label="提交人" width="110px" prop="submitter_name" />
      <el-table-column label="备注" min-width="260px" prop="remark" />
      <el-table-column label="申请详情" min-width="260px">
        <template slot-scope="{row}">
          <span v-if="row.pay_time && row.pay_time !== ''">付款时间：{{ row.pay_time }}<br/></span>
          <span v-if="row.use_time && row.use_time !== ''">使用日期：{{ row.use_time }}<br/></span>
          <span v-if="row.return_time && row.return_time !== ''">归还日期：{{ row.return_time }}<br/></span>
          <span v-if="row.word && row.word !== ''">金额大写：{{ row.word }}<br/></span>
          <span v-if="row.addr && row.addr !== ''">使用工地：{{ row.addr }}<br/></span>
          <span v-if="row.detailed && row.detailed !== ''">订单明细：{{ row.detailed }}<br/></span>
          <span v-if="row.stage && row.stage !== ''">期别：{{ row.stage }}<br/></span>
          <span v-if="row.purpose && row.purpose !== ''">用途：{{ row.purpose }}<br/></span>
          <span v-if="row.speed && row.speed !== ''">小包进度：{{ row.speed }}<br/></span>
          <span v-if="row.basis && row.basis !== ''">付款依据：{{ row.basis }}<br/></span>
          <span v-if="row.condition && row.condition !== ''">付款条件：{{ row.condition }}<br/></span>
          <span v-if="row.cycle && row.cycle !== ''">付款周期：{{ row.cycle }}<br/></span>
          <span v-if="row.reason && row.reason !== ''">用途说明：{{ row.reason }}<br/></span>
          <span v-if="row.remark && row.remark !== ''">备注：{{ row.pw_remark }}<br/></span>
          <span v-if="row.fund_remark && row.fund_remark !== ''">备注：{{ row.fund_remark }}<br/></span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="90px" fixed="right">
        <template slot-scope="{row}">
          <el-dropdown>
            <el-button type="primary" size="mini">
              操作<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="handleDelete(row)">删 除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
    <Dialog ref="dialog" :get-data="getList" :info="dialog" />
  </div>
</template>

<script>
import page from '@/utils/page'
import { payments, delPayment } from '@/api/finance/fund'
import ProFilter from '@/components/ProFilter'
import AccountSelect from '@/myComponents/AccountSelect'
import SupplierSelect from '@/myComponents/SupplierSelect'

export default {
  name: '',
  components: { ProFilter, AccountSelect, SupplierSelect },
  extends: page,
  props: {
    reqList: {
      default: payments,
      type: Function
    },
    reqDel: {
      default: delPayment,
      type: Function
    }
  },
  data() {
    return {
      price: {},
      dField: ['id', 'account_id', 'pro_id', 'ctm_id', 'type', 'money', 'collection_date', 'remark']
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getListAfter(e) {
      this.price = e.summary
    },
    getSummaries() {
      const sums = []
      sums[0] = '合计'
      sums[4] = this.app.toFix(this.price.money, 2)
      return sums
    }
  }
}
</script>
<style scoped>
</style>
